<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>门店管理表</title>
    <link rel="stylesheet" href="../../styles/common.css"/>
    <link rel="stylesheet" href="../../styles/page.css"/>
</head>
<body>
<div id="app">
    <div class="dashboard-container" id="category-app">
        <div class="container">
            <!--增查-->
            <div class="tableBar">
                <el-input
                        v-model="input"
                        placeholder="请输入门店名称"
                        style="width: 250px"
                        clearable
                        @keyup.enter.native="handleQuery"
                >
                    <i
                            slot="prefix"
                            class="el-input__icon el-icon-search"
                            style="cursor: pointer"
                            @click="init"
                    ></i>
                </el-input>
                <div class="tableLab">
                    <el-button
                            type="primary"
                            @click="addStore('add')"
                    >
                        + 新建门店
                    </el-button>
                </div>
            </div>
            <!--表格-->
            <el-table
                    :data="tableData"
                    stripe
                    class="tableBox"
            >
                <!--<el-table-column
                        type="selection"
                        width="27"
                ></el-table-column>-->
                <el-table-column
                        label="评分排名"
                        type="index"
                        width="80"
                        align="center"
                >
                </el-table-column>
                <el-table-column
                        prop="score"
                        label="评分"
                        align="center"
                >
                </el-table-column>
                <el-table-column
                        prop="categoryName"
                        label="套餐名称"
                        align="center"
                ></el-table-column>

                <el-table-column
                        prop="address"
                        label="地址"
                        align="center"
                ></el-table-column>
                <el-table-column
                        prop="phone"
                        label="电话"
                        align="center"
                >
                </el-table-column>
                <el-table-column
                        prop="workTime"
                        label="营业时间"
                        align="center"
                        width="176"
                >
                </el-table-column>
                <el-table-column
                        prop="commentTotal"
                        label="评价条数"
                        align="center"
                >
                </el-table-column>

                <el-table-column
                        label="操作"
                        width="160"
                        align="center"
                >
                    <template slot-scope="scope">
                        <el-button
                                type="text"
                                size="small"
                                class="blueBug"
                                @click="addStore(scope.row.id)"
                        >
                            修改
                        </el-button>
                        <!--<el-button
                                type="text"
                                size="small"
                                class="delBut non"
                                @click="deleteHandle('单删', scope.row.id)"
                        >
                            删除
                        </el-button>-->
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                    class="pageList1"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="counts"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
            ></el-pagination>
        </div>
    </div>
</div>
</div>

</body>
<script src="../../plugins/vue/vue.js"></script>
<script src="../../plugins/element-ui/index.js"></script>
<link rel="stylesheet" href="../../plugins/element-ui/index.css">
<script src="../../plugins/axios/axios.min.js"></script>
<script src="../../js/request.js"></script>
<script src="../../api/store.js"></script>
<script src="../../js/echarts.js"></script>

<script>
    new Vue({
        el: "#app",
        mounted() {
        },
        created() {
            this.init()
        },
        methods: {
            async init() {
                const params = {
                    page: this.page,
                    pageSize: this.pageSize,
                    categoryName: this.input ? this.input : undefined,
                }
                console.log(params)
                await getCategoryStorePage(params).then(res => {
                    if (String(res.code) === '1') {
                        this.tableData = res.data.records || []
                        this.counts = Number(res.data.total)
                    } else {
                        this.$message.error(res.msg || '操作失败')
                    }
                }).catch(err => {
                })

            },
            // 添加
            addStore(st) {
                if (st === 'add'){
                    window.parent.menuHandle({
                        id: '7',
                        url: 'page/store/add.html',
                        name: '添加店铺'
                    },true)
                } else {
                    window.parent.menuHandle({
                        id: '7',
                        url: 'page/store/add.html?id='+st,
                        name: '修改店铺'
                    },true)
                }
            },
            handleSizeChange(val) {
                this.pageSize = val
                this.init()
            },
            handleCurrentChange(val) {
                this.page = val
                this.init()
            },
            // 关闭弹窗
            handleClose(st) {
                this.classData.dialogVisible = false
            },
            handleQuery() {
                this.page = 1;
                this.init();
            },
        },
        data() {
            return {
                tableData: [],
                dialogVisible: false,
                classData: {
                    'title': '添加菜品分类',
                    'dialogVisible': false,
                    'categoryId': '',
                    'name': '',
                    sort: ''
                },
                counts: 0,
                page: 1,
                pageSize: 10,
                input:'',
            }
        }
    })
</script>
</html>